#include "RobotLauncher.hpp"

// master thread
master_thrd::master_thrd(int *i,  std::string thread_mame, ThreadType thread_type, ThreadStartType start_type):
    CThread(thread_mame, thread_type, start_type),_var(i)
{
}

master_thrd::~master_thrd(){
    //no memory cleaned
}

void master_thrd::init()
{
        (*_var) = 0;

}

void master_thrd::task()
{
    CThread::lock();
        (*_var)++; 

    std::cout << "Thread" <<  getThreadName().c_str() << ": i = " << *_var << std::endl; 
    CThread::unlock();
}

// slave thread
slave_thrd::slave_thrd(int *i, std::string thread_mame, ThreadType thread_type, ThreadStartType start_type):
    CThread(thread_mame, thread_type, start_type),_var(i)
{
}

slave_thrd::~slave_thrd(){
    //no memory cleaned
}

void slave_thrd::init()
{
    (*_var) = 0;
}

void slave_thrd::task()
{
    CThread::lock();
    (*_var)++; 
    std::cout << "Thread" <<  getThreadName().c_str() << ": i = " << *_var << std::endl; 
    CThread::unlock();
}